home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / automa_1 / frmclien.frm < prev    next >
Text File  |  1999-08-23  |  3KB  |  114 lines

  1. VERSION 5.00
  2. Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
  3. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  4. Begin VB.Form frmClient 
  5.    Caption         =   "Client"
  6.    ClientHeight    =   1335
  7.    ClientLeft      =   60
  8.    ClientTop       =   345
  9.    ClientWidth     =   4680
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   1335
  12.    ScaleWidth      =   4680
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin MSWinsockLib.Winsock wsTCP 
  15.       Index           =   0
  16.       Left            =   120
  17.       Top             =   480
  18.       _ExtentX        =   741
  19.       _ExtentY        =   741
  20.       _Version        =   393216
  21.    End
  22.    Begin VB.CommandButton cmdSend 
  23.       Caption         =   "Send"
  24.       Height          =   315
  25.       Left            =   1800
  26.       TabIndex        =   2
  27.       Top             =   600
  28.       Width           =   1215
  29.    End
  30.    Begin MSComDlg.CommonDialog dlg 
  31.       Left            =   600
  32.       Top             =   480
  33.       _ExtentX        =   847
  34.       _ExtentY        =   847
  35.       _Version        =   393216
  36.    End
  37.    Begin VB.CommandButton cmdBrowse 
  38.       Caption         =   "Browse"
  39.       Height          =   315
  40.       Left            =   3360
  41.       TabIndex        =   1
  42.       Top             =   120
  43.       Width           =   1215
  44.    End
  45.    Begin VB.TextBox txtFile 
  46.       Height          =   315
  47.       Left            =   120
  48.       TabIndex        =   0
  49.       Top             =   120
  50.       Width           =   3135
  51.    End
  52.    Begin VB.Label lblStatus 
  53.       BorderStyle     =   1  'Fixed Single
  54.       Height          =   315
  55.       Left            =   0
  56.       TabIndex        =   3
  57.       Top             =   1020
  58.       Width           =   4695
  59.    End
  60. End
  61. Attribute VB_Name = "frmClient"
  62. Attribute VB_GlobalNameSpace = False
  63. Attribute VB_Creatable = False
  64. Attribute VB_PredeclaredId = True
  65. Attribute VB_Exposed = False
  66. '==============================================
  67. 'Written by Igor Ostrovsky (igor@ostrosoft.com)
  68. 'Visual Basic 911 (http://www.ostrosoft.com/vb)
  69. '==============================================
  70. Option Explicit
  71.  
  72. Dim buffer() As Byte
  73. Dim lBytes As Long
  74.  
  75. Private Sub cmdBrowse_Click()
  76.   dlg.ShowOpen
  77.   txtFile = dlg.filename
  78. End Sub
  79.  
  80. Private Sub cmdSend_Click()
  81.   cmdSend.Enabled = False
  82.   lBytes = 0
  83.   ReDim buffer(FileLen(dlg.filename) - 1)
  84.   Open dlg.filename For Binary As 1
  85.   Get #1, 1, buffer
  86.   Close #1
  87.   Load wsTCP(1)
  88.   wsTCP(1).RemoteHost = "localhost"
  89.   wsTCP(1).RemotePort = 1111
  90.   wsTCP(1).Connect
  91.   lblStatus = "Connecting..."
  92. End Sub
  93.  
  94. Private Sub wsTCP_Close(Index As Integer)
  95.   lblStatus = "Connection closed"
  96.   Unload wsTCP(1)
  97. End Sub
  98.  
  99. Private Sub wsTCP_Connect(Index As Integer)
  100.   lblStatus = "Connected"
  101.   wsTCP(1).SendData buffer
  102. End Sub
  103.  
  104. Private Sub wsTCP_SendComplete(Index As Integer)
  105.   lblStatus = "Send complete"
  106.   Unload wsTCP(1)
  107.   cmdSend.Enabled = True
  108. End Sub
  109.  
  110. Private Sub wsTCP_SendProgress(Index As Integer, ByVal bytesSent As Long, ByVal bytesRemaining As Long)
  111.   lBytes = lBytes + bytesSent
  112.   lblStatus = lBytes & " out of " & UBound(buffer) & " bytes sent"
  113. End Sub
  114.